package nero.yncc.com.createart.activity;

import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.HashMap;

import nero.yncc.com.createart.R;
import nero.yncc.com.createart.adapter.AdapterIndexChangjing;
import nero.yncc.com.createart.base.BaseActivity;
import nero.yncc.com.createart.base.Constants;
import nero.yncc.com.createart.bean.ChangjingBean;
import nero.yncc.com.createart.custom.IconView;
import nero.yncc.com.createart.fragment.FragmentCollection;
import nero.yncc.com.createart.utils.HttpUtils;
import nero.yncc.com.createart.utils.LIstPopUtil2;

/**
 * Created by nero on 17-6-26.
 */
@ContentView(R.layout.activity_collection)
public class ActivityCollection extends BaseActivity {
    @ViewInject(R.id.vp_main)
    ViewPager vp_main;
    @ViewInject(R.id.tv_good)
    TextView tv_good;
    @ViewInject(R.id.tv_taocan)
    TextView tv_taocan;

//    //场景套餐
//    ArrayList<ChangjingBean> arrayList_changjing;
//    AdapterIndexChangjing adapterIndexChangjing;

    @Override
    protected void initView() {
        super.initView();
        setTitleBarTitle("我的收藏");

    }

    @Override
    protected void initData() {
        super.initData();
        change(0);
    }

    private void change(int state){
//        tv_good.setBackgroundResource(R.color.white);
        tv_good.setTextColor(getResources().getColor(R.color.textColorGray));
//        tv_taocan.setBackgroundResource(R.color.white);
        tv_taocan.setTextColor(getResources().getColor(R.color.textColorGray));
        if(state==0){
            tv_good.setTextColor(getResources().getColor(R.color.project_yellow));
        }else{
            tv_taocan.setTextColor(getResources().getColor(R.color.project_yellow));
        }

    }

    @Override
    protected void initListener() {
        super.initListener();
        vp_main.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                FragmentCollection fragmentCollection=new FragmentCollection();
                Bundle bundle=new Bundle();
                switch (position){
                    case 0:
                        bundle.putInt("type",FragmentCollection.STATE_GOODS);
                        break;
                    case 1:
                        bundle.putInt("type",FragmentCollection.STATE_CHANGJING);
                        break;
                }
                fragmentCollection.setArguments(bundle);
                return fragmentCollection;
            }

            @Override
            public int getCount() {
                return 2;
            }
        });
        vp_main.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                change(position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

        tv_good.setOnClickListener(this);
        tv_taocan.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()){
            case R.id.tv_good:
                vp_main.setCurrentItem(0);
                break;
            case R.id.tv_taocan:
                vp_main.setCurrentItem(1);
                break;
        }
    }

    @Override
    protected void doClick(int id) {
        super.doClick(id);
        switch (id) {
            case R.id.rl_style:
                showPop(POP_STYLE);
                break;
            case R.id.rl_space:
                showPop(POP_SPACE);
                break;
            case R.id.rl_house_type:
                showPop(POP_HOUSETYPE);
                break;
            case R.id.icon_back:
                finish();
                break;
        }
    }

    private static final int POP_STYLE = 1, POP_SPACE = 2, POP_HOUSETYPE = 3;


    private void showPop(int id) {

    }


    int page = 1, pagesize = 10;
    boolean canLoad = true;

    @Override
    protected void getData() {
        super.getData();
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("user_id", userBean.getUser_id());
        HttpUtils.get(this, Constants.API_COLLECTION, hashMap, null, HttpUtils.TYPE_NOTHING, new HttpUtils.HttpCallback() {
            @Override
            public void success(String msg, Object json) {

            }

            @Override
            public void fail(String failMsg) {

            }
        });
    }
}
